﻿using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace Silent.WCF.Base.Common
{
    public class SessionShutdownBehaviour : IEndpointBehavior
    {
        private readonly bool m_automaticInputSessionShutdown;

        public SessionShutdownBehaviour(bool automaticInputSessionShutdown)
        {
            m_automaticInputSessionShutdown = automaticInputSessionShutdown;
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {

        }
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {

        }
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            endpointDispatcher.DispatchRuntime.AutomaticInputSessionShutdown = m_automaticInputSessionShutdown;
        }
        public void Validate(ServiceEndpoint endpoint)
        {

        }
    }
}